package com.he.service.mailbox;

import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import com.github.pagehelper.PageHelper;
import com.he.dao.MailBoxMapper;
import com.he.pojo.MailBox;
import com.he.pojo.MailBoxExample;
@Service
public class MailBoxServiceImpl implements MailBoxServiceI {
	@Autowired
	MailBoxMapper boxMapper;
	@Override
	public List<MailBox> getNoPageMailBox(MailBoxExample mailBoxExample) {
		// TODO Auto-generated method stub
		return boxMapper.selectByExample(mailBoxExample);
	}

	@Override
	public MailBox getMailBoxById(int id) {
		// TODO Auto-generated method stub
		return boxMapper.selectByPrimaryKey(id);
	}

	@Override
	public int insert(MailBox mailBox) {
		// TODO Auto-generated method stub
		return boxMapper.insertSelective(mailBox);
	}

	@Override
	public int update(MailBox mailBox) {
		// TODO Auto-generated method stub
		return boxMapper.updateByPrimaryKeySelective(mailBox);
	}

	@Override
	public int delete(int id) {
		// TODO Auto-generated method stub
		return boxMapper.deleteByPrimaryKey(id);
	}

	@Override
	public List<MailBox> getPageMailBox(MailBoxExample mailBoxExample, MailBox mailBox) {
		//如果withPage属性值为1代表要分页
		if(mailBox.getWithPage()==1) {
			PageHelper.startPage(mailBox.getPageNo(), mailBox.getPageSize());
		}
		return boxMapper.selectByExample(mailBoxExample);
	}

}
